package com.lb.videoplay.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lb.videoplay.R;
import com.lb.videoplay.model.IndustryModel;

import java.util.List;

public class HobbyAdapter extends BaseQuickAdapter<IndustryModel.HobbiesBean, BaseViewHolder> {

    private int mSelect = -1;   //选中项

    public HobbyAdapter(int layoutResId, @Nullable List<IndustryModel.HobbiesBean> data) {
        super(layoutResId, data);
    }

    public void changeSelected(int positon) { //刷新方法
        if (positon != mSelect) {
            mSelect = positon;
            notifyDataSetChanged();
        }
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    @Override
    protected void convert(BaseViewHolder helper, IndustryModel.HobbiesBean item) {
        helper.addOnClickListener(R.id.ll_select);
        helper.setBackgroundRes(R.id.iv_check, item.isSelect() ? R.drawable.hobby_pressed : R.drawable.hobby_normal);
        helper.setText(R.id.tv_industry_name, item.getHobbyName());
    }
}
